import { createBrowserRouter } from "react-router-dom";
import App from "../App";

export const childrenRouter = [
    {
        path: 'index',
        title: '首页',
        lazy: async () => {
            const { default: Index } = await import('../pages/index/Index')
            return {
                element: <Index />
            }
        }
    },
    {
        path: 'order',
        title: '订单',
        lazy: async () => {
            const { default: Order } = await import('../pages/order/Index')
            return {
                element: <Order />
            }
        },
       
    },
    {
        path: 'message',
        title: '消息',
        lazy: async () => {
            const { default: Message } = await import('../pages/message/Index')
            return {
                element: <Message />
            }
        },
        children: [
            {
                path: 'message1',
                title: '翻译',
                lazy: async () => {
                    const { default: Message1 } = await import('../pages/message/message1/Index')
                    return {
                        element: <Message1 />
                    }
                },
            },
            {
                path: 'list',
                title: '分析页',
                lazy: async () => {
                    const { default: List } = await import('../pages/message/list/Index')
                    return {
                        element: <List />
                    }
                },
            }
        ]
    }
]

const routes = createBrowserRouter([
    {
        path: '/',
        element: <App />,
        children: childrenRouter
    },
    {
        path: '/login',
        lazy: async () => {
            const { default: Login } = await import('../pages/login/Index')
            return {
                element: <Login />
            }
        }
    }
])
export default routes